var _n20;
var cc__extends = __extends;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_requireComponent = cc__decorator.requireComponent;
var ccp_menu = cc__decorator.menu;
var ccp_property = cc__decorator.property;
var def_Ipha_PageViewBoost = function (t) {
  function _ctor() {
    // 创建实例并设置默认属性
    const instance = null !== t && t.apply(this, arguments) || this;

    // 初始化实例属性
    instance.pageTipLabel = null; // 页面提示标签
    instance.pageView = null; // 当前页面视图
    instance.nowPageIndex = null; // 当前页面索引

    return instance; // 返回实例
  }
  cc__extends(_ctor, t);
  _ctor.prototype.start = function () {
    this.updatePageTipLable();
    this.updatePageScale();
  };
  _ctor.prototype.addPgae = function (t) {
    this.pageView.addPage(t);
  };
  _ctor.prototype.updatePageTipLable = function (t) {
    //this.pageTipLable && (this.pageTipLable.string = t && "number" == typeof t ? t + " / " + this.pageView.getPages().length : this.pageView.getCurrentPageIndex() + 1 + " / " + this.pageView.getPages().length);
    // 更新页面提示标签的内容
    if (this.pageTipLable) {
      const totalPages = this.pageView.getPages().length; // 获取总页面数
      const currentPageIndex = this.pageView.getCurrentPageIndex() + 1; // 获取当前页面索引（加1以便从1开始计数）

      // 根据 t 的类型设置页面提示的字符串
      if (t && typeof t === "number") {
        this.pageTipLable.string = `${t} / ${totalPages}`; // 如果 t 是数字，显示当前页与总页数
      } else {
        this.pageTipLable.string = `${currentPageIndex} / ${totalPages}`; // 否则，显示当前页（从1开始）与总页数
      }
    }
  };
  _ctor.prototype.updatePageScale = function () { };
  _ctor.prototype.OnBtnPageToRight = function () {
    // 检查当前页面索引是否不是最后一页
    if (this.pageView.getCurrentPageIndex() !== this.pageView.getPages().length - 1) {
      // 滚动到下一个页面，持续时间为0.3秒
      this.pageView.scrollToPage(this.pageView.getCurrentPageIndex() + 1, 0.3);
    }
  };
  _ctor.prototype.OnBtnPageToLeft = function () {
    if (this.pageView.getCurrentPageIndex() != 0) {
      this.pageView.scrollToPage(this.pageView.getCurrentPageIndex() - 1, 0.3);
    }
  };
  _ctor.prototype.update = function () {
    if (this.pageView.isScrolling() || this.pageView.isAutoScrolling()) {
      this.updatePageScale();
    }
    this.updatePageTipLable();
  };
  _ctor.prototype.onDestroy = function () { };
  cc__decorate([ccp_property({
    type: cc.Label,
    displayName: "页面文字提示"
  })], _ctor.prototype, "pageTipLable", undefined);
  cc__decorate([ccp_property({
    type: cc.PageView,
    displayName: "页面视图 组件"
  })], _ctor.prototype, "pageView", undefined);
  return cc__decorate([ccp_ccclass, ccp_menu("ipha组件/pageView增强"), ccp_requireComponent(cc.PageView)], _ctor);
}(cc.Component);
exports.default = def_Ipha_PageViewBoost;